package com.swt.service.impl.S_impl;

import com.swt.dao.S_dao.GetVipCardDao;
import com.swt.domain.*;
import com.swt.service.S_service.GetVipCardService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.smartcardio.Card;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service(value = "S_getVipCardService")
public class GetVipCardServiceImpl implements GetVipCardService {
    /*注入dao*/
    @Resource(name = "S_getVipCardDao")
    private GetVipCardDao getVipCardDao;
    @Override
    public List<Member> getVipCardByClubId(int id) {
        List<Member> list = getVipCardDao.getVipCardDao(id);
        return list;
    }

    @Override
    public Shop getClubById(int clubId) {
        /*调用dao*/
        Shop shop = getVipCardDao.getClubById(clubId);
        return shop;
    }

    @Override
    public Map<String, List<Vipcard>> getVipCardByCourseId(int courseid,int userid) {
        //1.先根据课程id找到对应的课程
        Course course = getVipCardDao.getCourseByCourseId(courseid);
        //2.根据课程找到对应的店铺id和bossid
        int clubid=course.getCourseClubid();
        int bossid=course.getClubClubId();
        //3.根据bossid找到店铺会员卡里该店铺下面所有的状态为0  即通用的会员卡
        List<Vipcard> useCard = getVipCardDao.getUseCard(clubid, userid, bossid);
        //4.再查该店铺的单独使用的卡
        List<Vipcard> aloneCard=getVipCardDao.getAloneCard(clubid,userid);
        Map<String,List<Vipcard>> set=new HashMap<>();
        set.put("all",useCard);
        set.put("alone",aloneCard);
        return set;
    }
}
